CLS
DEFINT K, Z, R
DIM zero AS INTEGER
INPUT "Vvedite kol-vo strok i stolbcov: "; n
DIM Ar(1 TO n, 1 TO n) AS INTEGER
RANDOMIZE TIMER
FOR i = 1 TO n
FOR j = 1 TO n
Ar(i, j) = INT(RND * 10 - 5)
PRINT Ar(i, j)
NEXT j
NEXT i
FOR i = 1 TO n
k = 0
z = 0
FOR j = 1 TO n
IF Ar(i, j) = 0 THEN zero = zero + 1
IF Ar(i, j) >= 0 THEN
temp = Ar(i, j)
k = k + 1
IF k = 1 THEN fpos = temp
ELSE
temp = Ar(i, j)
z = z + 1
IF z = 1 THEN fneg = temp
END IF
NEXT j
IF zero = 0 AND fpos = 0 OR fneg = 0 THEN
PRINT "Stolbec ne imeet i otric i poloj elementa"
ELSE
PRINT "Perv. poloj: "; fpos
PRINT "Perv. otric: "; fneg
PRINT "Raznica: "; ABS(fneg) + ABS(fpos)
END IF
NEXT i
END
Тестирование выполнено в программе QB64 ( Скачать )